//
//  HSHomeWorkCell.swift
//  HomeSchoolDemo
//
//  Created by rimi on 16/10/8.
//  Copyright © 2016年 赖虹宇. All rights reserved.
//

import UIKit

class HSHomeWorkCell: UITableViewCell {
    //作业标题
    var workTitle = UILabel()
    //科目名
    var subjectsName = UIButton()
    //老师名
    var tName = UILabel()
    //发布时间
    var createDate = UILabel()
    //提交状态
    var subStatus  = UIButton()
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setUpUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //设置自定义cell的布局且约束
    func setUpUI(){
        //作业标题
        workTitle = UILabel()
        addSubview(workTitle)
        workTitle.snp.makeConstraints { (make) in
            make.top.equalTo(16.5)
            make.left.equalTo(16.5)
            make.width.equalTo(150)
            make.height.equalTo(30)
        }
        workTitle.textColor = UIColor().colorWithHex(0x4c4c4c)
        
        //科目--用textfield 方便设置圆角
        subjectsName.layer.cornerRadius = 10
        subjectsName.setTitleColor(UIColor().colorWithHex(0x009ee7), for: .normal)
        subjectsName.layer.borderColor = UIColor().colorWithHex(0x009ee7).cgColor
        subjectsName.layer.borderWidth = 1
        subjectsName.titleLabel?.font = UIFont.systemFont(ofSize: 11)
        
        //设置这个按钮不可交互
        subjectsName.isUserInteractionEnabled = false
        addSubview(subjectsName)
        subjectsName.snp.makeConstraints { (make) in
            make.left.equalTo(workTitle.snp.left)
            make.top.equalTo(workTitle.snp.bottom).offset(8)
            make.width.equalTo(44)
            make.height.equalTo(20)
        }
        //教师名
        tName.textColor = UIColor().colorWithHex(0x4c4c4c)
        tName.font = UIFont.systemFont(ofSize: 15)
        tName.textAlignment = .right
        addSubview(tName)
        tName.snp.makeConstraints { (make) in
            make.top.equalTo(16.5)
            make.left.equalTo(workTitle.snp.right).offset(40)
            make.width.equalTo(60)
            make.height.equalTo(25)
        }
        //发布时间
        createDate.textColor = UIColor().colorWithHex(0xcccccc)
        createDate.textAlignment = .center
        createDate.font = UIFont.systemFont(ofSize: 15)
        addSubview(createDate)
        createDate.snp.makeConstraints { (make) in
            make.top.equalTo(tName.snp.bottom).offset(16.5)
            make.right.equalTo(tName.snp.right)
            make.bottom.equalTo(subjectsName.snp.bottom)
        }
        //提交状态按钮
        subStatus.layer.cornerRadius = 30
        addSubview(subStatus)
        subStatus.snp.makeConstraints { (make) in
            make.top.equalTo(tName.snp.top)
            make.left.equalTo(tName.snp.right).offset(20)
            make.width.height.equalTo(60)
        }
        
    }
   
    
    
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
